package com.zhu.transaction.mapper.imp;

import com.zhu.transaction.mapper.FavoriteMapper;
import com.zhu.transaction.pojo.Favorite;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Zhu
 * @createtime 2021/2/12-11:40
 */
@Repository
public class FavoriteMapperImp implements FavoriteMapper {
    @Autowired
    SqlSession sqlSession;

    @Override
    public int addFavoriteProduct(Favorite favorite) {
        return sqlSession.getMapper(FavoriteMapper.class).addFavoriteProduct(favorite);
    }

    @Override
    public int deleteFavoriteProductById(String favoriteId) {
        return sqlSession.getMapper(FavoriteMapper.class).deleteFavoriteProductById(favoriteId);
    }

    @Override
    public Favorite queryFavoriteProductByUserIdAndProductId(String userId, String productId) {
        return sqlSession.getMapper(FavoriteMapper.class).queryFavoriteProductByUserIdAndProductId(userId, productId);
    }

    @Override
    public List<Favorite> queryFavoriteProductByPage(String userId, Integer index) {
        return sqlSession.getMapper(FavoriteMapper.class).queryFavoriteProductByPage(userId, index);
    }

    @Override
    public int queryFavoriteProductsNum(String userId) {
        return sqlSession.getMapper(FavoriteMapper.class).queryFavoriteProductsNum(userId);
    }

    @Override
    public int updateProductState(String productId, Integer newState) {
        return sqlSession.getMapper(FavoriteMapper.class).updateProductState(productId, newState);
    }
}
